<?php


class ListAction extends Action {
    public function index(){
    		session("bigtype",null);
    		session("middletype",null);
    		session("smalltype",null);
    	
    	
    		$bigtype = $_GET['bigtype'];
    		session("bigtype",$bigtype);
    		if(!empty($_GET['middletype'])){
    			$middletype = $_GET['middletype'];
    			session("middletype",$middletype);
    		}
    		if(!empty($_GET['smalltype'])){
    			$smalltype = $_GET['smalltype'];
    			session("smalltype",$smalltype);
    		}
    		
    		
    		
    		
    		
    		
    		$this->display();
    }
    public function getList(){
    		$info['bigtype'] = $_SESSION['bigtype'];
    		if(!empty($_SESSION['middletype'])){
    			$info['middletype'] = $_SESSION['middletype'];
    		}
    		if(!empty($_SESSION['smalltype'])){
    			$info['smalltype'] = $_SESSION['smalltype'];
    		}
    		
    		$goods = M("good");
    		$list=$goods->where($info)->select();
    		
    		foreach($list as $k=>$v){
    			$list[$k]["imgurl"]=explode(',',$v["imgurl"]);
    		}
    		$res['data']=$list;
    		$res['bigtype'] = $_SESSION['bigtype'];
    		$res['middletype'] = $_SESSION['middletype'];
    		$res['smalltype'] = $_SESSION['smalltype'];
    		$this->ajaxReturn($res);
    }
    
    public function getshopcar(){
    		$person['username'] = $_SESSION['username'];
    		$users = M("users");
    		$data = $users->where($person)->find();
    		$shopcar['userid'] = $data['id'];
    		$shopcart = M("shopcar");
    		$res = $shopcart->where($shopcar)->select();
    		if($res){
    			for($i = 0;$i<count($res);$i++){
	    			$goods = M("good");
	    			$good['id']=$res[$i]['goodid'];
	    			$goodinfo=$goods->where($good)->find();
		    		$goodinfo["imgurl"]=explode(',',$goodinfo["imgurl"])[0];
	    			$info['goodinfo'][$i]=$goodinfo;
	    		}
    			$info['data']=$res;
    			$info['count']=$res[0]['goodid'];
    			$info['status']=1;
    		}else{
    			$info['data']="";
    			$info['status']=2;
    		}
    		$this->ajaxReturn($info);
    		
    }
    
    public function exitlogin(){
    		session("username",null);
    		$info['info']="清除成功";
    		$info['status']=1;
    		$this->ajaxReturn($info);
    }
    
    
}



?>